package zuoye1;

import java.util.Scanner;

public class StringDemo {
    public static void main(String[] args) {
        while (true) {
            System.out.println("请输入一个邮箱：");
            Scanner sc=new Scanner(System.in);
            String str=sc.next();
            int count1=0;
            int count2=0;
            int x=0;
            int y=0;
            for (int i = 0; i < str.length(); i++) {
                String str1=str.substring(i,i+1);
                if (str1.equals("@")) {
                    count1++;
                    x=i;
                }
                if (str1.equals(".")) {
                    count2++;
                    y=i;
                }
            }
            if (count1==1&&count2==1&&x<(y-1)&&y!=str.length()-1) {
                System.out.println("合法");
            }else{
                System.out.println("不合法");
            }
        }
    }

}
